<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport"
        content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="__STATIC__/web/js/rem.js"></script>
    <link rel="stylesheet" href="__STATIC__/web/css/public.css">
    <link rel="stylesheet" href="__STATIC__/web/css/login.css">
    <script src="__STATIC__/web/js/jquery.js"></script>
    <link rel="stylesheet" href="__STATIC__/web/css/bui.css">
    <script src="__STATIC__/web/js/bui.js"></script>
    <title>登录</title>
</head>

<body>
    <div class="header-top">欢迎登陆山科大技术转移公共服务平台</div>
    <div class="user-login">
        <div class="user-name">
            <span>账号</span>
            <input type="text" placeholder="请输入账号" id="username">
        </div>
    </div>
    <div class="user-login">
        <div class="user-pwd">
            <span>密码</span>
            <input type="password" placeholder="请输入密码" id="pwd">
        </div>
    </div>

    <div class="verification-code">
        <input type="text" placeholder="请输入验证码" id="verifica">
        <img src="{:captcha_src()}"   id="captcha" onclick="this.src='{:captcha_src()}?seed='+Math.random()" height="38" width="150"
             alt="captcha"/>
    </div>
    <div class="btn">
        <button class="submit" onclick="submit()">登录</button>
    </div>
    <div class="pwd-reg">
        <a href="{:url('forgetPwd')}">忘记密码</a>
        <a href="{:url('signup')}">注册</a>
    </div>
    <script>
        var yanzheng = 0;
        function GetVerification() {
            var timestamp = Date.parse(new Date());
            yanzheng = timestamp
            $('#verificas').attr('src', 'https://api.it120.cc/zhuyuan98/verification/pic/get?key=' + timestamp)
        }
        GetVerification();
        $('#verificas').click(function () {
            GetVerification();
        })
        function submit() {
            if ($('#username').val() == '' || $('#username').val().length == 0) {
                bui.alert('请填写用户名')
            } else if ($('#pwd').val() == '' || $('#pwd').val().length == 0) {
                bui.alert('请填写密码')
            } else {
                if ($('#verifica').val() == '' || $('#verifica').val().length == 0) {
                    bui.alert('请填写验证码')
                } else {
                    const account = $("#username").val();
                    const password = $("#pwd").val();
                    const code = $("#verifica").val();
                    const data = {account,password,code};
                    console.log(data)
                    $.post("{:url('doLogin')}",data,function (res) {
                        console.log(res)
                        if (res.code === 1){
                            window.location.href = "{:url('/index')}"
                        }else{
                            bui.alert(res.msg)
                        }
                    })
                }
            }
        }
    </script>
</body>

</html>